package my.jieh.tips.util.collection;

/**
 * <p>Title: Core Java Technologies Tech Tips</p>
 * <p>Description:
 *
 * </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: Blueimp</p>
 * @author jieh
 * @version 1.0
 */
import java.util.*;

public class DemoTreeMap {
  public static void main(String args[]) {
    java.util.logging.Logger log = java.util.logging.Logger.getAnonymousLogger();
    //Create a tree map
    TreeMap tm = new TreeMap();

    // Put elements in the map
    tm.put("Carrots", new Integer(12));
    tm.put("Potatoes", new Integer(30));
    tm.put("Onions", new Integer(15));
    tm.put("Apples", new Integer(40));
    tm.put("Cherries", new Integer(300));

    //Check size of tree map
    System.out.println("The size of this tree map is " + tm.size() +
                       " element pairs.");

    //
    Set entries = tm.entrySet();
    Iterator it = entries.iterator();
    while (it.hasNext()) {
      Map.Entry entry = (Map.Entry) it.next();
      System.out.println(entry.getKey() + " : "
                         + entry.getValue());
    }
    System.out.println();

    java.util.LinkedList ll = new java.util.LinkedList();
    for (int i = 0; i < 30; i++) {
      ll.add(String.valueOf(i));
    }
    log.info("" + ll);
    log.info("" + ll.subList(0, 10));
  }
}